<template>
  <div class="body">

    <view class="page-top page-top2">
      <view class="jf-ye">
        <view><text>{{ score.score_num }}</text></view>
        <view><text>积分余额</text></view>
      </view>

      <view class="jf-dh">
        <view class="jf-dh-left">
          <image src="/static/images/a13.png"></image>
        </view>
        <view class="jf-dh-right"  @click="toexchange">
          <view><text>积分兑换</text></view>
          <view><text>点击进入</text></view>
        </view>
        <div style="clear:both"></div>
      </view>
    </view>

    <van-tabs :active="active">

      <van-tab title="收入">
        <view class="jf-hcont">
          <ul>
            <li v-for="(item, index) in list.list" :key="index" v-if="item.action === 1">
              <view class="ms2 clearfix">
                <view class="ms2-left">
                  <span class="time">{{ item.create_time }}</span>
                  <view class="jy" style="margin-top: 30px;">{{ item.content }}
                    <van-tag v-if="item.status === 0" round type="warning" size="medium">待审核</van-tag>
                    <van-tag v-if="item.status === 1" round type="success" size="medium">审核成功</van-tag>
                    <van-tag v-if="item.status === 2" round type="danger" size="medium">审核失败</van-tag>
                  </view>
                </view>
                <view class="ms2-right">+{{ item.num }}</view>
              </view>
            </li>
          </ul>
        </view>
      </van-tab>

      <van-tab title="提现">
        <view class="jf-hcont">
          <ul>
            <li v-for="(item, index) in list.list" :key="index" v-if="item.action === 2">
              <view class="ms2 clearfix">
                <view class="ms2-left">
                  <span class="time">{{ item.create_time }}</span>
                  <view class="jy" style="margin-top: 30px;">{{ item.content }}
                    <van-tag v-if="item.status === 0" round type="warning" size="medium">待审核</van-tag>
                    <van-tag v-if="item.status === 1" round type="success" size="medium">审核成功</van-tag>
                    <van-tag v-if="item.status === 2" round type="danger" size="medium">审核失败</van-tag>
                  </view>
                </view>
                <view class="ms2-right ms2-right2">-{{ item.num }}</view>
              </view>
            </li>
          </ul>
        </view>
      </van-tab>

    </van-tabs>

  </div>
</template>

<script>
// 例如：import uploadFile from '@/components/uploadFile/uploadFile'


import {getScoreList, getUserScore} from "../../../requests/merchant";

let $this
export default {
  name: '',
  // import引入的组件需要注入到对象中才能使用
  components: {},
  props: {
    // patientIn: {
    //   type: Object,
    //   default () {
    //     return {}
    //   }
    // }
  },
  data() {
    // 这里存放数据
    return {
      active: 0,
      score: '',
      list: ''
    }
  },
  // 方法集合
  methods: {
    toexchange() {
      mpvue.navigateTo({
        url: "/pages/merchant/score/exchange/main",
      });
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    $this = this
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  onShow() {
    //获取总的积分
    getUserScore().then(res => {
      let resp = res.data
      if (resp.code === 0) {
        this.score = resp.data
      }
    })

    //获取积分列表
    getScoreList().then(res => {
      let resp = res.data
      if (resp.code === 0) {
        this.list = resp.data
      }
    })


  }
}
</script>

<style>
@import "index.css";
</style>
